package com.piggy.system.api.factory;

import cn.hutool.json.JSON;
import cn.hutool.json.JSONObject;
import com.piggy.common.core.web.domain.AjaxResult;
import com.piggy.system.api.RemoteFlowService;
import com.piggy.system.api.RemoteOssService;
import com.piggy.system.api.bo.FlowCompleteBo;
import com.piggy.common.core.domain.R;
import com.piggy.system.api.domain.SysOss;
import com.piggy.system.api.domain.SysUser;
import com.piggy.system.api.vo.FlowTaskVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;
import java.util.Map;

/**
 * ACT服务降级处理98
 *
 * @author shark
 */
@Component
public class RemoteFlowFallbackFactory implements FallbackFactory<RemoteFlowService> {
    private static final Logger log = LoggerFactory.getLogger(RemoteFlowFallbackFactory.class);

    @Override
    public RemoteFlowService create(Throwable throwable) {
        log.error("Activiti服务调用失败:{}", throwable.getMessage());
        return new RemoteFlowService()
        {

            @Override
            public AjaxResult confirmTheCurrentProcess(Integer type, Long orderId, String source) {
                return null;
            }

            @Override
            public AjaxResult checkNode(String nodeCheckName, Long orderId, boolean check, String source) {
                return null;
            }

            @Override
            public R<Map<String, String>> getTask(String businessKey, String source) {
                return R.fail("Activiti服务调用失败:" + throwable.getMessage());
            }

            @Override
            public R<Map<String, String>> getTaskByKey(String processDefinitionKey, String businessKey, String source) {
                return R.fail("Activiti服务调用失败:" + throwable.getMessage());
            }

            @Override
            public R<String> getTaskSingResult(String businessKey, String source) {
                return R.fail("Activiti服务调用失败:" + throwable.getMessage());
            }

            @Override
            public R<List<SysUser>> getAssignees(String key, Long orderId, String source) {
                return R.fail("Activiti服务调用失败:" + throwable.getMessage());
            }

            @Override
            public R<Map<String, Object>> createMainProcess(Long orderId, String source) {
                return R.fail("Activiti服务调用失败:" + throwable.getMessage());
            }

            @Override
            public R getFlowInstance(Map<String, Object> map, String source) {
                return R.fail("Activiti服务调用失败:" + throwable.getMessage());
            }

            @Override
            public R complete(FlowCompleteBo bo, String source) {
                return R.fail("Activiti服务调用失败:" + throwable.getMessage());
            }

            @Override
            public R<List<JSONObject>> queryCurrProcess(String key, Long orderId, String source) {
                return R.fail("Activiti服务调用失败:" + throwable.getMessage());
            }

            @Override
            public R<List<JSONObject>> getTaskListByBusinessKey(String processKeyForeclosure, String valueOf, String source) {
                return R.fail("Activiti服务调用失败:" + throwable.getMessage());
            }

            @Override
            public R<List<Map<String, Object>>> createHistoricTaskInstanceQuery(Long orderId, String source) {
                return R.fail("Activiti服务调用失败:" + throwable.getMessage());
            }

            @Override
            public R<Boolean> abPreliminaryReviewFailed(String processKey2, String valueOf, String aBpreliminaryReviewFailed, String source) {
                return R.fail("Activiti服务调用失败:" + throwable.getMessage());
            }


            @Override
            public R removeVariables(String taskId, List<String> removeList, String source) {
                return R.fail("Activiti服务调用失败:" + throwable.getMessage());
            }

            @Override
            public R removeVariable(String taskId, String i, String source) {
                return R.fail("Activiti服务调用失败:" + throwable.getMessage());
            }


            @Override
            public R<Boolean> getVariable(String taskId, String reviewMode, String source) {
                return R.fail("Activiti服务调用失败:" + throwable.getMessage());
            }

            @Override
            public R cleanVariable(String orderId, String processKey, List<String> removeList, String source) {
                return R.fail("Activiti服务调用失败:" + throwable.getMessage());
            }

            @Override
            public R<Boolean> isCompleteApproval(String orderId, Integer finalAssignee, String source) {
                return R.fail("Activiti服务调用失败:" + throwable.getMessage());
            }


            @Override
            public R<List<JSONObject>> getTaskListByKey(String valueOf, String source) {
                return R.fail("Activiti服务调用失败:" + throwable.getMessage());
            }

            @Override
            public R<Boolean> isPresent(String processKey, String businessKey, String source) {
                return R.fail("Activiti服务调用失败:" + throwable.getMessage());
            }

            @Override
            public R<List<FlowTaskVo>> getTaskVoByBusinessKey(String businessKey, String source) {
                return R.fail("Activiti服务调用失败:" + throwable.getMessage());
            }

        };
    }
}
